# @Time    : 2023/3/13 22:05
# @Author  : SunJian
# @Email   : 330160114@qq.com
# @File    : views.py
# @Software: PyCharm
"""
文件说明：

"""
from django import http
from django.contrib.auth.mixins import LoginRequiredMixin


class LoginRequiredJSONMixin(LoginRequiredMixin):
    """自定义LoginRequiredMixin
    如果用户未登录，响应JSON，且状态码为400
    """

    def handle_no_permission(self):
        return http.JsonResponse({'code': 400, 'errmsg': '用户未登录'})